from django.contrib import admin
from .models import Host, HostGroup, Project, Environment, User, UserGroup


@admin.register(Host)
class HostAdmin(admin.ModelAdmin):
    list_display = ['hostname', 'ip', 'port', 'status', 'host_group', 'environment', 'created_at']
    list_filter = ['status', 'host_group', 'environment']
    search_fields = ['hostname', 'ip']


@admin.register(HostGroup)
class HostGroupAdmin(admin.ModelAdmin):
    list_display = ['name', 'description', 'created_at']
    search_fields = ['name']


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ['name', 'code', 'description', 'created_at']
    search_fields = ['name', 'code']


@admin.register(Environment)
class EnvironmentAdmin(admin.ModelAdmin):
    list_display = ['name', 'env_type', 'project', 'created_at']
    list_filter = ['env_type', 'project']
    search_fields = ['name']


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
    list_display = ['username', 'email', 'real_name', 'role', 'user_group', 'is_active', 'created_at']
    list_filter = ['role', 'is_active', 'user_group']
    search_fields = ['username', 'email', 'real_name']


@admin.register(UserGroup)
class UserGroupAdmin(admin.ModelAdmin):
    list_display = ['name', 'description', 'created_at']
    search_fields = ['name']
